// 整个store仓库的配置文件
import {configureStore} from '@reduxjs/toolkit'
import {combineReducers} from 'redux';
import {persistStore, persistReducer} from 'redux-persist'
import storage from 'redux-persist/lib/storage' // 默认是 localStorage
import {userSlice} from './userSlice'
import {DICSlice} from './DIC'


// 持久化配置
const persistConfig = {
    key: "root",       // 存储的键名
    storage,           // 存储引擎
};


// 根 reducer
const rootReducer = combineReducers({
    userSlice: userSlice.reducer,
    DICSlice: DICSlice.reducer
});
// 创建持久化的 reducer
const persistedReducer = persistReducer(persistConfig, rootReducer);


const store = configureStore({
    reducer: persistedReducer
})
export const persistor = persistStore(store)
export default store
